﻿@{
    ViewData["Title"] = "Add";
    Layout = "~/Views/Shared/_Layout1.cshtml";
}
<title>商品添加</title>
<el-aside width="200px">
    <el-menu>
        <el-menu-item>
            <span slot="title"><el-link :underline="false" href="/community/index">商品列表</el-link></span>
        </el-menu-item>
        <el-menu-item>
            <span slot="title"><el-link :underline="false" href="/community/Add">添加商品</el-link></span>
        </el-menu-item>
        <el-menu-item>
            <span slot="title"><el-link :underline="false" href="/community/show">商品分类</el-link></span>
        </el-menu-item>
    </el-menu>
</el-aside>

<el-main>
    <h2 align="center">基本信息</h2>

    <form id="form" method="post">
        <table>
            <tr>
                <td><span style="color:red">*</span>商品名称</td>
                <td><input type="text" id="commodityName" name="commodityName" placeholder="请输入商品名称" /></td>
            </tr>
            <tr>
                <td><span style="color:red">*</span>商品货号</td>
                <td><input type="text" id="articleNumber" name="articleNumber" placeholder="请输入商品货号" /></td>
            </tr>
            <tr>
                <td><span style="color:red">*</span>价格</td>
                <td><input type="number" id="commodityPrice" name="commodityPrice" placeholder="请输入金额" /></td>
            </tr>
            <tr>
                <td></td>
                <td>
                    <input type="button" onclick="bb()" value="添加" />
                </td>
            </tr>
        </table>
    </form>
    <script>
        function bb(){
        var model={};
         model.commodityName=$("#commodityName").val();
         model.articleNumber=$("#articleNumber").val();
         model.commodityPrice=$("#commodityPrice").val();

        $.ajax({
             type: "post",
             url: "http://localhost:62874/api/Community/Add",
             data: model,
             dataType : "json",
             success: function(d){
                 if(d>0)
                 {
                      alert("1");
                      location.href="/Community/Index";
                 }
                 else{
                      alert("0");
                 }
             }
             });
        }


    </script>



</el-main>
